Page({
  data:{
    windhight:null,
    markers: [{
      iconPath: "/images/12.gif",
      id: 0,
      latitude: 30.441769,
      longitude: 114.295857,
      width: 50,
      height: 50
    }],
    polyline: [{
      points: [{
        longitude: 114.295857,
        latitude: 30.441769
      }, {
          longitude: 114.295857,
          latitude: 30.441769
      }],
      color: "#FF0000DD",
      width: 2,
      dottedLine: true
    }],
    controls: [{
      id: 1,
      iconPath: '/images/12.gif',
      position: {
        left: 0,
        top: 300 - 50,
        width: 50,
        height: 50
      },
      clickable: true
    }]
  },
  regionchange(e) {
    console.log(e.type)
  },
  markertap(e) {
    console.log(e.markerId)
  },
  controltap(e) {
    console.log(e.controlId)
  },
  onReady: function (e) {
    // 使用 wx.createMapContext 获取 map 上下文
    this.mapCtx = wx.createMapContext('myMap')
  },
  getCenterLocation: function () {
    this.mapCtx.getCenterLocation({
      success: function (res) {
        console.log(res.longitude)
        console.log(res.latitude)
      }
    })
  },
  // 自定义
  click: function (e) {
    wx.openLocation({
      latitude: 30.441769,
      longitude: 114.295857,
      scale: 20,
      name: '指舞科技',
      address: '武汉市江夏区黄家湖大道333号腾讯众创空间'
    })
  }, 
  /**
 * 生命周期函数--监听页面加载
 */
  onLoad: function (options) {
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
        var latitude = res.latitude
        var longitude = res.longitude
        var speed = res.speed
        var accuracy = res.accuracy
        console.log(res.latitude)
        console.log(res.longitude)
      }
    })
    var that = this
    wx.getSystemInfo({
      success: function (res) {
        console.log(res.model)
        console.log(res.pixelRatio)
        console.log(res.windowWidth)
        console.log(res.windowHeight)
        console.log(res.language)
        console.log(res.version)
        console.log(res.platform)
        that.setData({ windhight: res.windowHeight })
      }
    })
  },

  // 自定义
  moveToLocation: function () {
    this.mapCtx.moveToLocation()
  },
  translateMarker: function () {
    this.mapCtx.translateMarker({
      markerId: 0,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude: 30.441769,
        longitude: 114.295857,
      },
      animationEnd() {
        console.log('animation end')
      }
    })
  },
  includePoints: function () {
    this.mapCtx.includePoints({
      padding: [10],
      points: [{
        latitude: 30.441769,
        longitude: 114.295857,
      }, {
          latitude: 30.441769,
          longitude: 114.295857,
      }]
    })
  }
})